package com.zzyl.nursing.controller;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.domain.NursingTask;
import com.zzyl.nursing.dto.TaskCancelDto;
import com.zzyl.nursing.dto.TaskDoDto;
import com.zzyl.nursing.dto.TaskUpdateTimeDto;
import com.zzyl.nursing.service.INursingTaskService;
import com.zzyl.nursing.vo.NursingTaskDetailVo;
import com.zzyl.nursing.vo.NursingTaskVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 护理任务Controller
 * 
 * @author alexis
 * @date 2024-11-17
 */
@RestController
@RequestMapping("/nursing/task")
@Api(tags = "护理任务管理")
public class NursingTaskController extends BaseController {
    @Autowired
    private INursingTaskService nursingTaskService;

    /**
     * 查询护理任务列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "获取护理任务列表")
    public TableDataInfo<NursingTaskVo> list(@ApiParam(value = "护理任务查询条件") NursingTask nursingTask) {
        startPage();
        return nursingTaskService.selectNursingTaskVoList(nursingTask);
    }

    /**
     * 获取护理任务详细信息
     */
    @GetMapping("/{id}")
    @ApiOperation("获取护理任务详细信息")
    public R<NursingTaskDetailVo> selectNursingTaskDetail(@PathVariable("id")Integer id){
        return R.ok(nursingTaskService.selectNursingTaskDetail(id));
    }

    /**
     * 取消任务
     */
    @PutMapping("/cancel")
    @ApiOperation("取消任务")
    public AjaxResult cancel(@RequestBody TaskCancelDto taskCancelDto) {
        nursingTaskService.cancel(taskCancelDto);
        return success();
    }

    /**
     * 执行任务
     */
    @PutMapping("/do")
    @ApiOperation("执行任务")
    public AjaxResult doTask(@RequestBody TaskDoDto taskDoDto) {
        nursingTaskService.doTask(taskDoDto);
        return success();
    }

    /**
     * 任务改期
     */
    @PutMapping("/updateTime")
    @ApiOperation("任务改期")
    public AjaxResult updateTime(@RequestBody TaskUpdateTimeDto taskUpdateTimeDto) {
        nursingTaskService.updateTime(taskUpdateTimeDto);
        return success();
    }
}
